/* Copyright [c] 2018-2028 www.chungen90.com Allrights Reserved*/
#include "CGPlayer-SDL.h"
#include "SdlPlayer.h"


using namespace ChunGen::Client::Player;

CGPlayerSdl::CGPlayerSdl()
{
	 sdlPlayer = nullptr;
}
void CGPlayerSdl::Init()
{
	if(!sdlPlayer)
	{
		sdlPlayer = new SdlPlayer();
		sdlPlayer->Init();
	}
}

int CGPlayerSdl::Open(std::string inputUrl)
{
	int ret  = -1;
	if(sdlPlayer)
	{
		ret = sdlPlayer->OpenInput(inputUrl);
	}
	return ret;
}

void CGPlayerSdl::Play(HWND handle)
{
	if(sdlPlayer)
	{
		sdlPlayer->Play(handle);
	}
}

void  CGPlayerSdl::Seek(int seekTime)
{
	if(sdlPlayer)
	{
		sdlPlayer->Seek(seekTime);
	}
}

int  CGPlayerSdl::GetDuration()
{
	if(sdlPlayer)
	{
		return sdlPlayer->GetDurtion();
	}
	return 0;
}

void CGPlayerSdl::Close()
{
	if(sdlPlayer)
	{
		sdlPlayer->Close();
		delete sdlPlayer;
		sdlPlayer = nullptr;
	}
}




